package o;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Path.FillType;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import androidx.annotation.Nullable;
import o.dk.a;
import o.dk.b;

class dr extends Drawable {
    private static final double ˊ = Math.cos(Math.toRadians(45.0d));
    static d ˏ;
    private float ʻ;
    private boolean ʻॱ = true;
    private Path ʼ;
    private Paint ʽ;
    private float ˊॱ;
    private Paint ˋ;
    private float ˋॱ;
    private Paint ˎ;
    private boolean ˏॱ = true;
    private ColorStateList ͺ;
    private final int ॱ;
    private final int ॱˊ;
    private float ॱॱ;
    private boolean ॱᐝ = false;
    private final RectF ᐝ;
    private final int ᐝॱ;

    interface d {
        void ˎ(Canvas canvas, RectF rectF, float f, Paint paint);
    }

    dr(Resources resources, ColorStateList colorStateList, float f, float f2, float f3) {
        this.ॱˊ = resources.getColor(a.ˋ);
        this.ᐝॱ = resources.getColor(a.ˊ);
        this.ॱ = resources.getDimensionPixelSize(b.ˋ);
        this.ˋ = new Paint(5);
        ˋ(colorStateList);
        this.ˎ = new Paint(5);
        this.ˎ.setStyle(Style.FILL);
        this.ʻ = (float) ((int) (0.5f + f));
        this.ᐝ = new RectF();
        this.ʽ = new Paint(this.ˎ);
        this.ʽ.setAntiAlias(false);
        ˊ(f2, f3);
    }

    private void ˋ(ColorStateList colorStateList) {
        if (colorStateList == null) {
            colorStateList = ColorStateList.valueOf(0);
        }
        this.ͺ = colorStateList;
        this.ˋ.setColor(this.ͺ.getColorForState(getState(), this.ͺ.getDefaultColor()));
    }

    private int ˊ(float f) {
        int i = (int) (0.5f + f);
        if (i % 2 == 1) {
            return i - 1;
        }
        return i;
    }

    void ˎ(boolean z) {
        this.ʻॱ = z;
        invalidateSelf();
    }

    public void setAlpha(int i) {
        this.ˋ.setAlpha(i);
        this.ˎ.setAlpha(i);
        this.ʽ.setAlpha(i);
    }

    protected void onBoundsChange(Rect rect) {
        super.onBoundsChange(rect);
        this.ˏॱ = true;
    }

    private void ˊ(float f, float f2) {
        if (f < 0.0f) {
            throw new IllegalArgumentException("Invalid shadow size " + f + ". Must be >= 0");
        } else if (f2 < 0.0f) {
            throw new IllegalArgumentException("Invalid max shadow size " + f2 + ". Must be >= 0");
        } else {
            float ˊ = (float) ˊ(f);
            float ˊ2 = (float) ˊ(f2);
            if (ˊ > ˊ2) {
                if (!this.ॱᐝ) {
                    this.ॱᐝ = true;
                }
                ˊ = ˊ2;
            }
            if (this.ˋॱ != ˊ || this.ॱॱ != ˊ2) {
                this.ˋॱ = ˊ;
                this.ॱॱ = ˊ2;
                this.ˊॱ = (float) ((int) (((ˊ * 1.5f) + ((float) this.ॱ)) + 0.5f));
                this.ˏॱ = true;
                invalidateSelf();
            }
        }
    }

    public boolean getPadding(Rect rect) {
        int ceil = (int) Math.ceil((double) ˎ(this.ॱॱ, this.ʻ, this.ʻॱ));
        int ceil2 = (int) Math.ceil((double) ˋ(this.ॱॱ, this.ʻ, this.ʻॱ));
        rect.set(ceil2, ceil, ceil2, ceil);
        return true;
    }

    static float ˎ(float f, float f2, boolean z) {
        if (z) {
            return (float) (((double) (1.5f * f)) + ((1.0d - ˊ) * ((double) f2)));
        }
        return 1.5f * f;
    }

    static float ˋ(float f, float f2, boolean z) {
        if (z) {
            return (float) (((double) f) + ((1.0d - ˊ) * ((double) f2)));
        }
        return f;
    }

    protected boolean onStateChange(int[] iArr) {
        int colorForState = this.ͺ.getColorForState(iArr, this.ͺ.getDefaultColor());
        if (this.ˋ.getColor() == colorForState) {
            return false;
        }
        this.ˋ.setColor(colorForState);
        this.ˏॱ = true;
        invalidateSelf();
        return true;
    }

    public boolean isStateful() {
        return (this.ͺ != null && this.ͺ.isStateful()) || super.isStateful();
    }

    public void setColorFilter(ColorFilter colorFilter) {
        this.ˋ.setColorFilter(colorFilter);
    }

    public int getOpacity() {
        return -3;
    }

    void ˎ(float f) {
        if (f < 0.0f) {
            throw new IllegalArgumentException("Invalid radius " + f + ". Must be >= 0");
        }
        float f2 = (float) ((int) (0.5f + f));
        if (this.ʻ != f2) {
            this.ʻ = f2;
            this.ˏॱ = true;
            invalidateSelf();
        }
    }

    public void draw(Canvas canvas) {
        if (this.ˏॱ) {
            ˋ(getBounds());
            this.ˏॱ = false;
        }
        canvas.translate(0.0f, this.ˋॱ / 2.0f);
        ˊ(canvas);
        canvas.translate(0.0f, (-this.ˋॱ) / 2.0f);
        ˏ.ˎ(canvas, this.ᐝ, this.ʻ, this.ˋ);
    }

    private void ˊ(Canvas canvas) {
        Object obj;
        float f = (-this.ʻ) - this.ˊॱ;
        float f2 = (this.ʻ + ((float) this.ॱ)) + (this.ˋॱ / 2.0f);
        Object obj2 = this.ᐝ.width() - (2.0f * f2) > 0.0f ? 1 : null;
        if (this.ᐝ.height() - (2.0f * f2) > 0.0f) {
            obj = 1;
        } else {
            obj = null;
        }
        int save = canvas.save();
        canvas.translate(this.ᐝ.left + f2, this.ᐝ.top + f2);
        canvas.drawPath(this.ʼ, this.ˎ);
        if (obj2 != null) {
            canvas.drawRect(0.0f, f, this.ᐝ.width() - (2.0f * f2), -this.ʻ, this.ʽ);
        }
        canvas.restoreToCount(save);
        save = canvas.save();
        canvas.translate(this.ᐝ.right - f2, this.ᐝ.bottom - f2);
        canvas.rotate(180.0f);
        canvas.drawPath(this.ʼ, this.ˎ);
        if (obj2 != null) {
            canvas.drawRect(0.0f, f, this.ᐝ.width() - (2.0f * f2), this.ˊॱ + (-this.ʻ), this.ʽ);
        }
        canvas.restoreToCount(save);
        int save2 = canvas.save();
        canvas.translate(this.ᐝ.left + f2, this.ᐝ.bottom - f2);
        canvas.rotate(270.0f);
        canvas.drawPath(this.ʼ, this.ˎ);
        if (obj != null) {
            canvas.drawRect(0.0f, f, this.ᐝ.height() - (2.0f * f2), -this.ʻ, this.ʽ);
        }
        canvas.restoreToCount(save2);
        save2 = canvas.save();
        canvas.translate(this.ᐝ.right - f2, this.ᐝ.top + f2);
        canvas.rotate(90.0f);
        canvas.drawPath(this.ʼ, this.ˎ);
        if (obj != null) {
            canvas.drawRect(0.0f, f, this.ᐝ.height() - (2.0f * f2), -this.ʻ, this.ʽ);
        }
        canvas.restoreToCount(save2);
    }

    private void ˋ() {
        RectF rectF = new RectF(-this.ʻ, -this.ʻ, this.ʻ, this.ʻ);
        RectF rectF2 = new RectF(rectF);
        rectF2.inset(-this.ˊॱ, -this.ˊॱ);
        if (this.ʼ == null) {
            this.ʼ = new Path();
        } else {
            this.ʼ.reset();
        }
        this.ʼ.setFillType(FillType.EVEN_ODD);
        this.ʼ.moveTo(-this.ʻ, 0.0f);
        this.ʼ.rLineTo(-this.ˊॱ, 0.0f);
        this.ʼ.arcTo(rectF2, 180.0f, 90.0f, false);
        this.ʼ.arcTo(rectF, 270.0f, -90.0f, false);
        this.ʼ.close();
        float f = this.ʻ / (this.ʻ + this.ˊॱ);
        float[] fArr = new float[]{0.0f, f, 1.0f};
        f = 0.0f;
        this.ˎ.setShader(new RadialGradient(0.0f, f, this.ʻ + this.ˊॱ, new int[]{this.ॱˊ, this.ॱˊ, this.ᐝॱ}, fArr, TileMode.CLAMP));
        float f2 = 0.0f;
        this.ʽ.setShader(new LinearGradient(0.0f, (-this.ʻ) + this.ˊॱ, f2, (-this.ʻ) - this.ˊॱ, new int[]{this.ॱˊ, this.ॱˊ, this.ᐝॱ}, new float[]{0.0f, 0.5f, 1.0f}, TileMode.CLAMP));
        this.ʽ.setAntiAlias(false);
    }

    private void ˋ(Rect rect) {
        float f = this.ॱॱ * 1.5f;
        this.ᐝ.set(((float) rect.left) + this.ॱॱ, ((float) rect.top) + f, ((float) rect.right) - this.ॱॱ, ((float) rect.bottom) - f);
        ˋ();
    }

    float ॱ() {
        return this.ʻ;
    }

    void ॱ(Rect rect) {
        getPadding(rect);
    }

    void ˋ(float f) {
        ˊ(f, this.ॱॱ);
    }

    void ॱ(float f) {
        ˊ(this.ˋॱ, f);
    }

    float ˏ() {
        return (Math.max(this.ॱॱ, (this.ʻ + ((float) this.ॱ)) + (this.ॱॱ / 2.0f)) * 2.0f) + ((this.ॱॱ + ((float) this.ॱ)) * 2.0f);
    }

    float ˊ() {
        return (Math.max(this.ॱॱ, (this.ʻ + ((float) this.ॱ)) + ((this.ॱॱ * 1.5f) / 2.0f)) * 2.0f) + (((this.ॱॱ * 1.5f) + ((float) this.ॱ)) * 2.0f);
    }

    void ˊ(@Nullable ColorStateList colorStateList) {
        ˋ(colorStateList);
        invalidateSelf();
    }
}
